package com.ymttest.database.sqlwapper.shenqisettlement;

import java.util.HashMap;
import java.util.List;

import com.ymt.core.tool.Logger;
import com.ymt.database.SqlManager;
import com.ymttest.database.model.shenqisettlement.ShengpaySharingConvergeDetail;

public class ShengpaySharingConvergeDetailWrapper {
	
	SqlManager manager;

    public ShengpaySharingConvergeDetailWrapper() {
        manager = new SqlManager("shenqisettlement");
    }
    
    @SuppressWarnings("unchecked")
	public List<ShengpaySharingConvergeDetail> selectByConvergeId(Long convergeId) {
    	
    	List<ShengpaySharingConvergeDetail> result = manager
                .getSelectResults(
                        "com.ymttest.database.mapping.shenqisettlement.ShengpaySharingConvergeDetailMapper.selectByConvergeId",
                        convergeId);
        manager.commit();
        
		if (result.size() == 0) {
			Logger.comment("shengpay_sharing_converge_detail没有数据");
			
			return null;
		}
		
		return result;
    }
    
	@SuppressWarnings("unchecked")
	public ShengpaySharingConvergeDetail selectByConvergeIdAndDetailId(
			Long convergeId, Long detailId) {

		ShengpaySharingConvergeDetail shengpaySharingConvergeDetail = null;

		HashMap<String, Long> map = new HashMap<>();

		map.put("shengpay_sharing_converge_id", convergeId);
		map.put("settlement_detail_id", detailId);

		List<ShengpaySharingConvergeDetail> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.shenqisettlement.ShengpaySharingConvergeDetailMapper.selectByConvergeIdAndDetailId",
						map);
		manager.commit();

		if (result.size() == 0) {
			Logger.comment("shengpay_sharing_converge_detail没有数据");
		} else
			shengpaySharingConvergeDetail = result.get(0);

		return shengpaySharingConvergeDetail;
	}
    
    public static void main(String[] args) {
    	ShengpaySharingConvergeDetailWrapper wrapper = new ShengpaySharingConvergeDetailWrapper();
    	Logger.debug(wrapper.selectByConvergeId(200L).get(0).getSettlement_source_type());
    }
}
